package com.zpark.cloud.alibaba.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.zpark.cloud.alibaba.controller.sentinel.ConsumerControllerSentinel;
import com.zpark.cloud.alibaba.entity.Dept;
import com.zpark.cloud.alibaba.feign.IDeptFeign;
import com.zpark.cloud.alibaba.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @PackageName: com.zpark.cloud.alibaba.controller
 * @ClassName: ConsumerController
 * @Description:
 * @author: RZS
 * @date: 2023/6/21  15:43
 */
@RestController
@RequestMapping("/consumer")
public class ConsumerController {

    @Autowired
    private IDeptFeign deptFeign;

    @GetMapping("/sel_id/{id}")
    @SentinelResource(value = "findById", fallback = "findByIdSentinel", fallbackClass = ConsumerControllerSentinel.class)
    public ResponseResult<Dept> findById(@PathVariable("id") Integer id){

        return deptFeign.findById(id);
    }

    @GetMapping("/sel_all")
    @SentinelResource(fallback = "findAllSentinel", fallbackClass = ConsumerControllerSentinel.class)
    public ResponseResult<List<Dept>> findAll(){
        return deptFeign.findAll();
    }


}
